

local ESTEMOD = minetest.get_current_modname()

dofile(minetest.get_modpath(ESTEMOD) .. "/functions.lua")

--[[
    DEFINICIONES DE LOS NODOS Y RECETAS.
    Funciones de callback movidas a /functions.lua
]]--






--
-- Node definitions
--

minetest.register_node("flintgen:flintgen", {
	description = "Horno de flint",
	tiles = { "silexGen.png"
		-- "default_furnace_top.png", "default_furnace_bottom.png",
		-- "default_furnace_side.png", "default_furnace_side.png",
		-- "default_furnace_side.png", "default_furnace_front.png"
	},
	paramtype2 = "facedir",
	groups = {cracky=2},
	legacy_facedir_simple = true,
	is_ground_content = false,
	sounds = default.node_sound_stone_defaults(),

	can_dig = can_dig,

	on_timer = flintgen.furnace_node_timer,

	on_construct = function(pos)
		local meta = minetest.get_meta(pos)
		local inv = meta:get_inventory()
		inv:set_size('src', 1)
		inv:set_size('fuel', 1)
		inv:set_size('dst', 4)
		flintgen.furnace_node_timer(pos, 0)
	end,

	on_metadata_inventory_move = function(pos)
		minetest.get_node_timer(pos):start(1.0)
	end,
	on_metadata_inventory_put = function(pos)
		-- start timer function, it will sort out whether furnace can burn or not.
		minetest.get_node_timer(pos):start(1.0)
	end,
	on_metadata_inventory_take = function(pos)
		-- check whether the furnace is empty or not.
		minetest.get_node_timer(pos):start(1.0)
	end,
	on_blast = function(pos)
		local drops = {}
		default.get_inventory_drops(pos, "src", drops)
		default.get_inventory_drops(pos, "fuel", drops)
		default.get_inventory_drops(pos, "dst", drops)
		drops[#drops+1] = "flintgen:flintgen"
		minetest.remove_node(pos)
		return drops
	end,

	allow_metadata_inventory_put = allow_metadata_inventory_put,
	allow_metadata_inventory_move = allow_metadata_inventory_move,
	allow_metadata_inventory_take = allow_metadata_inventory_take,
})

minetest.register_node("flintgen:flintgen_active", {
	description = "Horno de flint",
	tiles = { "silexGen_active.png",
		-- "default_furnace_top.png", "default_furnace_bottom.png",
		-- "default_furnace_side.png", "default_furnace_side.png",
		-- "default_furnace_side.png",
		{
			image = "default_furnace_front_active.png",
			backface_culling = false,
			animation = {
				type = "vertical_frames",
				aspect_w = 16,
				aspect_h = 16,
				length = 1.5
			},
		}
	},
	paramtype2 = "facedir",
	light_source = 8,
	drop = "flintgen:flintgen",
	groups = {cracky=2, not_in_creative_inventory=1},
	legacy_facedir_simple = true,
	is_ground_content = false,
	sounds = default.node_sound_stone_defaults(),
	on_timer = flintgen.furnace_node_timer,
	on_destruct = function(pos)
		stop_furnace_sound(pos)
	end,

	can_dig = can_dig,

	allow_metadata_inventory_put = allow_metadata_inventory_put,
	allow_metadata_inventory_move = allow_metadata_inventory_move,
	allow_metadata_inventory_take = allow_metadata_inventory_take,
})

minetest.register_craft({
	output = "flintgen:flintgen",
	recipe = {
		{"group:stone", "group:stone", "group:stone"},
		{"default:stone", "group:wood", "default:stone"},
		{"default:stone", "default:stone", "default:stone"},
	}
})